package com.tjp.eight.ui.fragment.setpassword;

import com.tjp.eight.base.BasePresenterImpl;
import com.tjp.eight.constant.UrlConstant;
import com.tjp.eight.net.NetCallBack;
import com.tjp.eight.net.SubscribeCallBack;

import okhttp3.MediaType;
import okhttp3.RequestBody;

/**
 * Created by Administrator on 2017/3/3.
 */
public class SetPassPresenter extends BasePresenterImpl<SetPassView> {
    public SetPassPresenter(SetPassView view) {
        attachView(view);
    }

    private setPassService passService = SetPassNetWork.getRetrofit(UrlConstant.BaseUrl).create(setPassService.class);

    public void setPass(String json) {
        RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), json);
        addSubscription(passService.setPass(requestBody), new SubscribeCallBack<>(new NetCallBack<SetPassModel>() {
            @Override
            public void onSuccess(SetPassModel model) {
                view.setPass(model);
            }

            @Override
            public void onFails(int code, String msg) {
                view.onFail(msg);
            }

            @Override
            public void onCompleted() {

            }
        }));
    }
}
